package com.web.service;

import com.web.entity.*;
import com.web.mapper.DetailsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DetailsService {
    @Autowired
    private DetailsMapper detailsMapper;
    public List<Chargestock> queryAllFromChargestock(){
        return this.detailsMapper.queryAllFromChargestock();
    }
    public Chargestock queryFromChargestockById(Integer id){
        return this.detailsMapper.queryByIdFromChargestock(id);
    }
    public void updateStatusById(int id){
        this.detailsMapper.updateStatusById(id);
    }
//    public void insertFixing(Fixing fixing){
//        int id;
//        String userid ;
//        String time ;
//        String description;
//        String phone ;
//        id=fixing.getId();
//        userid=fixing.getUserid();
//        time=fixing.getTime();
//        description=fixing.getDescription();
//        phone=fixing.getPhone();
//        this.detailsMapper.insertFixing(id,userid,time,description ,phone);
//    }

    public void insertFixing(Fixing fixing){

        this.detailsMapper.insertFixing(fixing);
    }
    public List<Restore> queryAllFromFixingJoinChargestock(){
        //System.out.println(this.detailsMapper.queryAllFromFixingJoinChargestock());
        return this.detailsMapper.queryAllFromFixingJoinChargestock();
    }

    public void updateStatusFromFixingByIdAndTime(Weixiutable weixiutable){
        int id=weixiutable.getId();
        String time=weixiutable.getTime();
        System.out.println("id:"+id);
        System.out.println("time:"+time);
        Key k=new Key();
        k.setTime(time);
        k.setId(id);
        this.detailsMapper.updateStatusFromFixingByIdAndTime(k);
    }

    public void insertWeixiutable(Weixiutable weixiutable){

        this.detailsMapper.insertWeixiutable(weixiutable);
    }
    public List<Weixiutable> queryAllFromWeixiutable(){

        return this.detailsMapper.queryAllFromWeixiutable();
    }
}
